    $(function(){

      // Initialize card flip
      $('.card.hover').hover(function(){
        $(this).addClass('flip');
      },function(){
        $(this).removeClass('flip');
      });

      // Make card front & back side same

      $('.card').each(function() {
        var front = $('.card .front');
        var back = $('.card .back');
        var frontH = front.height();
        var backH = back.height();

        

        if (backH > frontH) {
          front.height(backH - 8);
        }
      });

      // Initialize tabDrop
      $('.tabdrop').tabdrop({text: '<i class="fa fa-th-list"></i>'});
      
      //generate pie charts
      $('.easypiechart').easyPieChart();

      //animate numbers on cards
      $("#users-count").animateNumbers(Math.round( Math.random() * 1000 ));
      $("#orders-count").animateNumbers(Math.round( Math.random() * 100 ));
      $("#sales-count").animateNumbers(Math.round( Math.random() * 10000 ));
      $("#visits-count").animateNumbers(Math.round( Math.random() * 10000 ));

      //update instance every 5 sec
      window.setInterval(function() {

        //animate numbers on cards
        $( '#users-count' ).animateNumbers( Math.round( Math.random() * 1000 ) );
        $("#orders-count").animateNumbers(Math.round( Math.random() * 100 ));
        $("#sales-count").animateNumbers(Math.round( Math.random() * 10000 ));
        $("#visits-count").animateNumbers(Math.round( Math.random() * 10000 ));

        //refresh every pie chart
        $('.easypiechart').each(function() {
          $(this).data('easyPieChart').update(Math.floor(100*Math.random()));
        });

      }, 5000);

      //animate numbers with class .animate-number with data-value attribute
      $(".animate-number").each(function() {
        var value = $(this).data('value');
        var duration = $(this).data('animation-duration');

        $(this).animateNumbers(value, true, duration, "linear");
      });

      //animate progress bars
      $('.animate-progress-bar').each(function(){
        var progress =  $(this).data('percentage');

        $(this).css('width', progress);
      })

      //show tooltips
      $('#topTooltip, #rightTooltip, #bottomTooltip, #leftTooltip').tooltip();

      //jGrowl notifications
      $("#defaultGrowl").click(function() {
        $.jGrowl("Hello world!");
      });

      $("#stickyGrowl").click(function() {
        $.jGrowl("Stick this!", { sticky: true });
      });

      $("#headerGrowl").click(function() {
        $.jGrowl("A message with a header", { header: 'Important' });
      });

      $("#longerGrowl").click(function() {
        $.jGrowl("A message that will live a little longer.", { life: 10000 });
      });

      $("#specialGrowl").click(function() {
        $.jGrowl("A message with a beforeClose callback and a different opening animation.", {
          beforeClose: function(e,m) {
            alert('About to close this notification!');
          },
          animateOpen: {
            height: 'show'
          }
        });
      });

      //initialize typeahead
      $('#typeahead').typeahead({
        name: 'States',
        local: ["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Dakota","North Carolina","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"]
      });

      //initialize datepicker
      $('#datepicker').datepicker({
        todayHighlight: true
      });

      //initialize chosen
      $(".chosen-select").chosen({disable_search_threshold: 10});

      //initialize range slider
      $('#rangeSlider').noUiSlider({
        range: [10,40],
        start: [20,30],
        connect: true
      });

      //initialize slider
      $('#slider').noUiSlider({
        range: [0,100],
        start: [20],
        handles: 1
      });

      //initialize color picker sliders
      $('.slider').noUiSlider({
         range: [0,255]
        ,start: 127
        ,handles: 1
        ,connect: "lower"
        ,orientation: "vertical"
        ,serialization: {
          resolution: 1
        }
        ,slide: function(){

          var color = 'rgb(' + $("#red").val()
             + ',' + $("#green").val()
             + ',' + $("#blue").val()
             + ')';

          $(".result").css({
             background: color
            ,color: color
          });
        }
      });

      //set width for label on Inline Select
      var setLabelWidth = function() {
        var parentWidth = $('.inlineSelect.inline').width();
        var childrenLength = $('.inlineSelect.inline li').length;

        $('.inlineSelect.inline li label, .inlineSelect.inline li.title').css('width', ((parentWidth / childrenLength)) + 'px');
      }

      setLabelWidth();

      $(window).resize(function() {
        setLabelWidth();
      });

    })
